<template>
  <div>
    <f-table ref='table' rowKey='detailsId' :showSetting='true' :tableColumns='columns' :scroll='{x:true}' :multiple='false' :operator='operator' :autoLoad='false' :params='queryParam' :api='api.erpSearch.saleDetailList' handler='exportListHandler'>
         <span slot='orderNo' slot-scope='text, record, index'>
            <span v-clipboard:copy='text' v-clipboard:success='onCopy' style='cursor:pointer'>{{ text }}</span>
        </span>
      <span slot='saleType' slot-scope='text, record'>
        <template>
        <span>
           <a-tag v-if='text=="CKA"'>销售出库</a-tag>
            <a-tag v-if='text=="CKJ"'>销售退回</a-tag>
            <a-tag v-if='text=="CKI"'>退补差价</a-tag>
            <a-tag v-if='text=="CKB"'>调拨出库</a-tag>
            <a-tag v-if='text=="CKG"'>其他出库</a-tag>
            <a-tag v-if='text=="CKF"'>移出出库</a-tag>
            <a-tag v-if='text=="CKL"'>领用出库</a-tag>
            <a-tag v-if='text=="CKE"'>赠品出库</a-tag>
            <a-tag v-if='text=="CKC"'>报损出库</a-tag>
            <a-tag v-if='text=="CKD"'>盘亏出库</a-tag>

            <a-tag v-if='text=="RKB"'>采购验收</a-tag>
            <a-tag v-if='text=="RKN"'>进货退出</a-tag>
            <a-tag v-if='text=="RKM"'>退补差价</a-tag>
            <a-tag v-if='text=="RKF"'>商品损溢</a-tag>
            <a-tag v-if='text=="RKI"'>报升入库</a-tag>
            <a-tag v-if='text=="RKD"'>盘盈入库</a-tag>
            <a-tag v-if='text=="RKA"'>期初入库</a-tag>
        </span>
        </template>
      </span>
    </f-table>
  </div>
</template>
<script>
import api from "./../../js/api"

export default {
  name: "SaleDetails",
  components: {},
  data() {
    let me = this
    //操作按钮
    let operator = []
    let customFlag = this.$store.state.user.customFlag
    return {
      api: Object.assign(api, this.api),
      //列表初始化查询参数
      queryParam: {
        companyId: this.$store.state.user.companyId
      },
      tableObj: null,
      superAdmin: this.superAdmin,
      // 表头
      columns: [
        {
          title: '#',
          width: '70px',
          align: 'center',
          fixed: 'left',
          customRender: (text, record, index) => index + 1
        },
        {
          title: '单据日期',
          width: '100px',
          fixed: 'left',
          dataIndex: 'orderDate'
        },
        {
          title: '订单编号',
          align: 'left',
          width: '130px',
          fixed: 'left',
          dataIndex: 'orderNo',
          scopedSlots: { customRender: 'orderNo' }
        },
        {
          title: '方式名称',
          align: 'left',
          width: '80px',
          dataIndex: 'saleType',
          scopedSlots: { customRender: 'saleType' }
        },
        {
          title: '单位名称',
          align: 'left',
          width: '80px',
          dataIndex: 'customName'
        },
        {
          title: '部门名称',
          align: 'left',
          width: '80px',
          dataIndex: 'deptName'
        },
        {
          title: '业务员',
          align: 'left',
          width: '80px',
          dataIndex: 'businessNo'
        },
        {
          title: '制单人',
          align: 'left',
          width: '100px',
          dataIndex: 'userName'
        },
        {
          title: '通用名称',
          align: 'left',
          width: '75px',
          dataIndex: 'tym'
        },
        {
          title: '规格',
          align: 'left',
          width: '120px',
          ellipsis: true,
          dataIndex: 'gg'
        },
        {
          title: '批号',
          align: 'left',
          width: '70px',
          dataIndex: 'ph'
        },
        {
          title: '件容',
          align: 'left',
          width: '70px',
          dataIndex: 'jr'
        },
        {
          title: '销售单价',
          align: 'left',
          width: '70px',
          dataIndex: 'hsdj'
        },
        {
          title: '数量',
          align: 'left',
          width: '70px',
          dataIndex: 'sl'
        },
        {
          title: '销售金额',
          align: 'left',
          width: '70px',
          dataIndex: 'hsje'
        },
        {
          title: '件数',
          align: 'left',
          width: '70px',
          dataIndex: 'js'
        },
        {
          title: '成本单价',
          align: 'left',
          width: '70px',
          dataIndex: 'wsdj'
        },
        {
          title: '成本金额',
          align: 'left',
          width: '70px',
          dataIndex: 'wsje'
        },
        {
          title: '效期',
          align: 'left',
          width: '100px',
          dataIndex: 'xq'
        },

        {
          title: '业务分类',
          align: 'left',
          width: '100px',
          dataIndex: 'ywfl',
          scopedSlots: { customRender: "ywfl" }
        },
        {
          title: '生产企业',
          align: 'left',
          width: '120px',
          ellipsis: true,
          dataIndex: 'scqy'
        },
        {
          title: '上市许可持有人',
          align: 'left',
          width: '120px',
          ellipsis: true,
          dataIndex: 'cyr'
        },
        {
          title: '单位',
          align: 'left',
          width: '70px',
          dataIndex: 'dw'
        },
        {
          title: '有效期至',
          align: 'left',
          width: '70px',
          dataIndex: 'yxqz'
        },
        {
          title: '生产日期',
          align: 'left',
          width: '70px',
          dataIndex: 'scrq'
        }, {
          title: '备注',
          align: 'left',
          width: '100px',
          dataIndex: 'br'
        }
      ],
      operator: operator
    }
  },
  created() {
  },
  mounted() {
    this.tableObj = this.$refs.table
  },
  methods: {
    onCopy() {
      this.$message.success("复制成功!")
    },
    setData(data) {
      if (data && data.orderNo) {
        this.queryParam.orderNo = data.orderNo
        this.$refs["table"].refresh(false)
      }
    }
  }
}
</script>
